package action;

import service.Param;
import service.UserService;
import bean.UserBean;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

@SuppressWarnings("serial")
public class UserAction extends ActionSupport {
    public String username;
    public String password;
    public String info;
    UserBean userBean = new UserBean();
    UserService userService = new UserService();

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getInfo() {
        return info;
    }

    public void setInfo(String info) {
        this.info = info;
    }

    public UserBean getUserBean() {
        return userBean;
    }

    public void setUserBean(UserBean userBean) {
        this.userBean = userBean;
    }

    public String login() {
        String info = null;
        info = userService.login(username, password);
        Param.username = this.username;
        this.info = info;
        ActionContext.getContext().getSession().put("username", Param.username);
        ActionContext.getContext().getSession().put("info", info);
        return SUCCESS;
    }

    public String getLoginUser() {
        ActionContext.getContext().getSession().put("username", Param.username);
        System.out.println("getLoginUser username:" + Param.username);
        return SUCCESS;
    }
}
